<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8" />
		<title>蓝莲花酒店官网 </title>
		<link rel="shortcut icon" th:href="@{/image/hotel.ico}" type="image/x-icon" />
		<link rel="stylesheet" type="text/css" th:href="@{/layui/css/layui.css}"/>
		<link rel="stylesheet" type="text/css" th:href="@{/layui/css/view.css}"/>
	</head>
	<body>
		<!--导航栏-->
		<div th:include="common/header :: html"></div>
		<!--<div  id="container"></div>-->

		<div class="layui-content">
			<div class="layui-row">
				<div class="layui-card">
					<div class="layui-card-body">
						<div class="form-box">
							<a href="#" style="float: right;margin-bottom: 10px;" th:href="@{/hotel/form}" class="layui-btn">新增</a>
							<table class="layui-table">
								<colgroup>
									<col width="300">
									<col width="200">
									<col>
									<col width="200">
								</colgroup>
								<thead>
								<tr>
									<th>酒店名称</th>
									<th>缩略图</th>
									<th>酒店地址</th>
									<th>操作</th>
								</tr>
								</thead>
								<tbody>
									<tr th:each="hotel:${hotelList}">
										<td th:text="${hotel.name}">贤心</td>
										<td th:text="${hotel.name}">贤心</td>
										<td th:text="${hotel.detailAddress}">1104975916@qq.com</td>
										<td>
											<a href="#" th:href="@{/hotel/form(id=${hotel.id})}" class="layui-btn layui-btn-sm">编辑</a>
											<button class="layui-btn layui-btn-sm layui-btn-danger" th:onclick="|delHotel(${hotel.id})|">删除</button>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script th:src="@{/layer/layer.js}"></script>
	<script type="text/javascript" th:src="@{/header/js/jquery-1.8.2.min.js}"></script>
	<script th:inline="javascript">
        /*<![CDATA[*/
        var contextPath = [[${#request.getContextPath()}]]; //获取当前应用路径
        /*]]>*/
	</script>
	<script type="text/javascript">
		function delHotel(hotelId) {
            layer.confirm('确认删除？', {
                btn: ['必须的', '算了吧'] //按钮
            }, function () {
                $.ajax({
                    url: contextPath + "/hotel/delete",
                    data: {"id": hotelId},
                    method: "post",
                    success: function (data) {
                        layer.msg('删除成功！', {icon: 1, time: 1000}, function () {
                            window.location.reload(true);
                        })
                    }
                })

            }, function () {
                layer.msg('取消成功', {
                    time: 1000, //20s后自动关闭
                });
            });
        }
	</script>
</html>